#include "uart_device.h"


struct uart_device g_stm32f103_uart1 = {
    .name = "stm32f103_uart1",
    .init = stm32f103_uart_init,
    .send = stm32f103_uart_send,
    .recv = stm32f103_uart_recv,
    .priv_data = &g_priv_data,
};

struct priv_struct g_priv_data = {
    .usart_handler = 0,
    .send_sem = NULL,
    .recv_sem = NULL,
    .send_queue = NULL,
    .recv_queue = NULL,
};


static int stm32f103_uart_init(struct uart_device *pDev, int baud, int data_bits, int stop_bits, int parity)
{
    // create semaphore for send and recv

    // create queue for send and recv


    while(1){};
    return 0;
}

static int stm32f103_uart_send(struct uart_device *pDev, unsigned char * data, int length, int timeout)
{
    /* trigger send */

    /* wait for send complete */

    while(1){};
    return 0;
}

static int stm32f103_uart_recv(struct uart_device *pDev, unsigned char * data, int timeout)
{
    /* trigger recv */

    /* wait for recv complete */

    while(1){};
    return 0;
}

struct uart_device g_uart_device[] = {
    &g_stm32f103_uart1,
};

struct uart_device * find_uart_device(char * name)
{
    for(int i = 0; i < sizeof(g_uart_device) / sizeof(g_uart_device[0]); i++)
    {
        if(strcmp(g_uart_device[i].name, name) == 0)
        {
            return &g_uart_device[i];
        }
    }
    return NULL;
}

